<?

class file_M extends ModelAbstract
{
	public function upfile()
	{
		//print_r($_FILES);
		$name = $_FILES['file']['name'];
		$type = $_FILES['file']['type'];
		$size = $_FILES['file']['size'];
		$tmp_name = $_FILES['file']['tmp_name'];//http://www.jb51.net/article/23912.htm
		if($db = virtualDb('','files.Model.xml'))
		{
			echo $db;
			$datax = './virtualdb/data/file.data.xml';
			$fdatax = new DOMDocument();
			if(!virtualDb('data','file.data.xml'))
			{//初始化
				copy($db,$datax);
				$fdatax -> load($datax);
				$data = $fdatax -> getElementsByTagName('data');
				$data ->setAttribute('name','文件存储XML文件');
				$data ->setAttribute('edit',sys_date(''));
				$data ->setAttribute('code','file.data.xml');
				//print_r($data);
				$fdatax->save($datax);
			}
			else//已经存在
			{
				$fdatax ->load($datax);
				$url = './filesNew/files/'.$name;echo $url;
				/*
				//浏览器信息--该扩展太缓慢
				$browser = get_browser(null, true);
				print_r($browser);
				*/
				if(is_file($url))
				{
					echo '<p>文件已经存在</p>';
					return;
				}
				else
				{
				//move_uploaded_file($tmp_name,$url);

				$documentElement = $fdatax -> documentElement;//根
				//print_r($documentElement);
				$Crfile = $fdatax ->createElement('file');
				
				$file = $fdatax -> getElementsByTagName('file');
				$file_len = $file -> length;
				$file_atrr = $file -> item($i);
				//$id = $file_atrr -> getAttribute('id');
				$file_atrr -> setAttribute('name',$name);
				$file_atrr -> setAttribute('type',$type);
				$file_atrr -> setAttribute('size',$size);
				$file_atrr -> setAttribute('url',$url);
				$file_atrr -> setAttribute('date',sys_date(''));
				$file_atrr -> getAttribute('ip',getRealIpAddr());
				$browser = $file_atrr -> getAttribute('browser');
				$platform = $file_atrr -> getAttribute('platform');
				$download = $file_atrr -> getAttribute('download');
				$remark = $file_atrr -> getAttribute('remark');//http://cz1.me/post/21
				
	
				//print_r($file);
				$fdatax->save($datax);
				

				}
			}
			


		}
		//var_dump($_FILES);
		//echo $name;
	}

	public function News()
	{
		header('Content-Type: text/html; charset=utf-8');
		$search = $_POST['search'];;
		//echo $search;
		//************1.新闻检索************
		$url = "http://op.juhe.cn/onebox/news/query";
		$appkey = '0f3d5769cb70dbbba9af150c98c6dae5';
		//$search = isset($_POST['search'])? $_GET['search'] : '李克强';
		$params = array(
			  "q" => $search,//需要检索的关键字,请UTF8 URLENCODE
			  "key" => $appkey,//应用APPKEY(应用详细页查询)
			  "dtype" => "json",//返回数据的格式,xml或json，默认json
		);
		$paramstring = http_build_query($params);
		$content = juhecurl($url,$paramstring);
		$result = json_decode($content,true);
		if($result){
			if($result['error_code']=='0'){
				//print_r($result);
				
				$dataSearch = $result['result'];
				foreach($dataSearch as $value)
				{
					echo '<p>';
					echo '<a href="'.$value['url'].'" target="_blank">'.$value['title'].'</a><br>';
					echo $value['content'].'<br>';
					echo '  :更新时间('.$value['pdate'].')：'.$value['pdate_src'].' 。来自<a href="javascript:void(0);">'.$value['src'].'</a>消息<br>';
					echo '</p>';
				}
				
			}else{
				echo $result['error_code'].":".$result['reason'];
			}
		}else{
			echo "请求失败";
		}
		//**************************************************
		 
	}

	public function api_function()
	{
		$id = $_POST['id'];
		header('Content-type:text/html;charset=utf-8');
		if($id == 'searchPhone')
		{
			// +----------------------------------------------------------------------
			// | JuhePHP [ NO ZUO NO DIE ]
			// +----------------------------------------------------------------------
			// | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.
			// +----------------------------------------------------------------------
			// | Author: Juhedata <info@juhe.cn>
			// +----------------------------------------------------------------------
			 
			//----------------------------------
			// 聚合数据-手机号码归属地查询API
			//----------------------------------
			
			$apiurl = 'http://apis.juhe.cn/mobile/get'; 
			$params = array(
			  'key' => '4fb8ed996cf1d4a7c7b53bfd1f363b40', //您申请的手机号码归属地查询接口的appkey
			  'phone' => $_POST['cellphone'] //要查询的手机号码
			);
			 
			$paramsString = http_build_query($params);
			 
			$content = @file_get_contents($apiurl.'?'.$paramsString);
			$result = json_decode($content,true);
			if($result['error_code'] == '0'){
				//print_R($result);
				/*
				"province":"浙江",
				"city":"杭州",
				"areacode":"0571",
				"zip":"310000",
				"company":"中国移动",
				"card":"移动动感地带卡"
				*/
				/*
				echo "省份：".$result['result']['province']."\r\n";
				echo "城市：".$result['result']['city']."\r\n";
				echo "区号：".$result['result']['areacode']."\r\n";
				echo "邮编：".$result['result']['zip']."\r\n";
				echo "运营商：".$result['result']['company']."\r\n";
				echo "类型：".$result['result']['card']."\r\n";

				*/
				echo '<p>查询结果：</p>';
				echo '<p><a href="javascript:void(0);">'.$result['result']['province'].'</a>省 <a href="javascript:void(0);">'.$result['result']['city'].'</a>市</p>';
				echo '<p>区号：<a href="javascript:void(0);">'.$result['result']['areacode'].'</a>，邮编：<a href="javascript:void(0);">'.$result['result']['zip'].'</a>，运营商：<a href="javascript:void(0);">'.$result['result']['company'].'</a>，卡类型：<a href="javascript:void(0);">'.$result['result']['card'].'</a></p>';
			}else{
				echo $result['reason']."(".$result['error_code'].")";
			}
		}


		if($id == 'searchidcar')
		{
			//配置您申请的appkey
			$appkey = "c3b579cebe350c3b10653bdc7da036ff";	 
			
			//************1.身份证信息查询************
			$url = "http://apis.juhe.cn/idcard/index";
			$params = array(
				  "cardno" => $_POST['idcard'],//身份证号码
				  "dtype" => "",//返回数据格式：json或xml,默认json
				  "key" => $appkey,//你申请的key
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					echo '<h4>基本信息</h4>';
					echo '<p>地区：<a href="javascript:void(0);">'.$result['result']['area'].'</a> ,性别：<a href="javascript:void(0);">'.$result['result']['sex'].'</a>，生日<a href="javascript:void(0);">'.$result['result']['birthday'].'</a></p>';
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}
			//**************************************************
			 
			 
			 
			 
			//************2.身份证泄漏查询************
			$url = "http://apis.juhe.cn/idcard/leak";
			$params = array(
				  "cardno" => $_POST['idcard'],//身份证号码
				  "dtype" => "",//返回数据格式：json或xml,默认json
				  "key" => $appkey,//你申请的key
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					echo '<h4>其他信息</h4>';
					echo '<p>状态:<a href="javascript:void(0);">'.$result['result']['tips'].'</a></p>';
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}
			//**************************************************
			 
			 
			 
			 
			//************3.身份证挂失查询************
			$url = "http://apis.juhe.cn/idcard/loss";
			$params = array(
				  "cardno" => $_POST['idcard'],//身份证号码
				  "dtype" => "",//返回数据格式：json或xml,默认json
				  "key" => $appkey,//你申请的key
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					echo '<p>是否挂失：<a href="javascript:void(0);">'.$result['result']['tips'].'</a></p>';
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}

		}

		if($id == 'searchweather')
		{
			//配置您申请的appkey
			$appkey = "ee5e861e756fd86e898075798f5781a5";
			 
			//************1.根据城市查询天气************
			$url = "http://op.juhe.cn/onebox/weather/query";
			$params = array(
				  "cityname" => $_POST['city'],//要查询的城市，如：温州、上海、北京
				  "key" => $appkey,//应用APPKEY(应用详细页查询)
				  "dtype" => "",//返回数据的格式,xml或json，默认json
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					$resultdate = $result['result']['data'];
					$realtime = $resultdate['realtime'];
					echo '<h4>即是时间</h4>';
					echo '<p>城市代码：('.$realtime['city_code'].')_<a href="javascript:void(0);" style="text-decoration:none; font-size:1.34em;">'.$realtime['city_name'].'</a>，<br>日期：'.$realtime['date'].' '.$realtime['time'].'。农历：'.$realtime['moon'].'</p>';
					$weather = $realtime['weather'];
					$wind = $realtime['wind'];
					echo '<p>温度：'.$weather['temperature'].'，湿度：'.$weather['humidity'].'， '.$weather['info'].'。<br>风向：'.$wind['direct'].'（'.$wind['power'].'）</p>';
					$life = $resultdate['life'];
					echo '<h4>生活</h4>';
					$chuanyi = $life['info']['chuanyi'];
					echo '<p>穿衣：('.$chuanyi['0'].')'.$chuanyi['1'].'<br></p>';
					$ganmao = $life['info']['ganmao'];
					echo '<p>感冒：('.$ganmao['0'].')'.$ganmao['1'].'<br></p>';
					$kongtiao = $life['info']['kongtiao'];
					echo '<p>空调：('.$kongtiao['0'].')'.$kongtiao['1'].'<br></p>';
					$wuran = $life['info']['wuran'];
					echo '<p>污染：('.$wuran['0'].')'.$wuran['1'].'<br></p>';
					$xiche = $life['info']['xiche'];
					echo '<p>洗车：('.$xiche['0'].')'.$xiche['1'].'<br></p>';
					$yundong = $life['info']['yundong'];
					echo '<p>运动：('.$yundong['0'].')'.$yundong['1'].'<br></p>';
					$ziwaixian = $life['info']['ziwaixian'];
					echo '<p>紫外线：('.$ziwaixian['0'].')'.$ziwaixian['1'].'<br></p>';
					echo '<h4>天气数据</h4>';
					$weathers = $resultdate['weather'];
					foreach($weathers as $value)
					{
						echo '<p>时间：'.$value['date'].'('.$value['week'].')，农历<a href="javascript:void(0);" style="text-decoration:none; font-size:1.11em;">'.$value['nongli'].'</a>。<br>【白天】'.$value['info']['day'][1].',温度'.$value['info']['day'][2].'，风向'.$value['info']['day'][3].'（'.$value['info']['day'][4].'）<br>【晚上】'.$value['info']['night'][1].',温度'.$value['info']['night'][2].'，风向'.$value['info']['night'][3].'（'.$value['info']['night'][4].'）</p>';
					}
					//print_r($weathers);
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}

		}

		if($id == 'tuling')
		{
			$url = "http://op.juhe.cn/robot/index";
			$appkey =  'f76419d19baef6edb0cd2bf70f6b1803';
			$params = array(
				  "key" => $appkey,//您申请到的本接口专用的APPKEY
				  "info" => $_POST['info'],//要发送给机器人的内容，不要超过30个字符
				  "dtype" => "",//返回的数据的格式，json或xml，默认为json
				  "loc" => "",//地点，如北京中关村
				  "lon" => "",//经度，东经116.234632（小数点后保留6位），需要写为116234632
				  "lat" => "",//纬度，北纬40.234632（小数点后保留6位），需要写为40234632
				  "userid" => "",//1~32位，此userid针对您自己的每一个用户，用于上下文的关联
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					echo '<p style="color:#0000cc;"><span style="font-size:1.2em;color:#006600;">图灵</span>：'.$result['result']['text'].'</p>';
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}
		}

		if($id == 'getDirveTips')
		{
			 
			//配置您申请的appkey
			$appkey = "03c8c3db9cbfa3f41e69db8156204dc2";
			 
			 
			//************1.题库接口************
			$url = "http://api2.juheapi.com/jztk/query";
			$params = array(
				  "key" => $appkey,//您申请的appKey
				  "subject" => $_POST['subject'],//选择考试科目类型，1：科目1；4：科目4
				  "model" => $_POST['modeltype'],//驾照类型，可选择参数为：c1,c2,a1,a2,b1,b2；当subject=4时可省略
				  "testType" => $_POST['testType'],//测试类型，rand：随机测试（随机100个题目），order：顺序测试（所选科目全部题目）
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					$resultD = $result['result'];
					foreach($resultD as $resultDirve)
					{
						$answer = $resultDirve['answer'];
						echo '<p>题号 '.$resultDirve['id'].'. '.$resultDirve['question'].'<br><span class="iamge"><img src="'.$resultDirve['url'].'"></span><br><span class="item"> <a href="javascript:void(0);" style="text-decoration:none;color:#006600;">'.$resultDirve['item1'].'</a>    <a href="javascript:void(0);" style="text-decoration:none;color:#0000ff;">'.$resultDirve['item2'].'</a> <a href="javascript:void(0);" style="text-decoration:none;color:#ff0000;">   '.$resultDirve['item3'].'</a>   <a href="javascript:void(0);" style="text-decoration:none;color:#006600;">'.$resultDirve['item4'].'</a></span> <br><span class="answer" style="display:none;">'.$resultDirve['item'.$answer].'</span><br><span class="explains" style="display:none;">'.$resultDirve['explains'].'</span></p>';
					}
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}
			//**************************************************
			 
			 
			 
			 /*
			//************2.answer字段对应答案************
			$url = "http://api2.juheapi.com/jztk/answers";
			$params = array(
				  "key" => $appkey,//您申请的appk
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					print_r($result);
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}
			//**************************************************
			 */
		}
		if($id == 'getWeiXunpage')
		{
			$url = "http://v.juhe.cn/weixin/query";
			$appkey = 'b014000b60fe029fbf978d821c517e35';
			$params = array(
				  "pno" => $_POST['page'],//当前页数，默认1
				  "ps" => "30",//每页返回条数，最大100，默认20
				  "key" => $appkey,//应用APPKEY(应用详细页查询)
				  "dtype" => "",//返回数据的格式,xml或json，默认json
			);
			$paramstring = http_build_query($params);
			$content = juhecurl($url,$paramstring);
			$result = json_decode($content,true);
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					$list = $result['result']['list'];
					foreach($list as $lvalue)
					{
						echo '<p><h4>'.$lvalue['id'].':<a href="'.$lvalue['url'].'" target="_blank">'.$lvalue['title'].'</a>（'.$lvalue['source'].'）<h4><br><span class="Weixinimg"><img src="'.$lvalue['firstImg'].'"</span></p>';
					}
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}

		}

		if($id == 'lastJokes')
		{
			$appkey = "f28e05dfd27f9c198ee33069592a9c72";
			$item = $_POST['item'];
			switch ($item)
			{
				case 'lastJokes':
					$url = "http://japi.juhe.cn/joke/content/text.from";
					$params = array(
						  "page" => $_POST['page'],//当前页数,默认1
						  "pagesize" => "20",//每次返回条数,默认1,最大20
						  "key" => $appkey,//您申请的key
					);
					$paramstring = http_build_query($params);
					$content = juhecurl($url,$paramstring);
					$result = json_decode($content,true);
					break;
				case 'lastserJokes':
					$url = "http://japi.juhe.cn/joke/content/list.from";
					$params = array(
						  "sort" => "desc",//类型，desc:指定时间之前发布的，asc:指定时间之后发布的
						  "page" => $_POST['page'],//当前页数,默认1
						  "pagesize" => "20",//每次返回条数,默认1,最大20
						  "time" => time(),//时间戳（10位），如：1418816972
						  "key" => $appkey,//您申请的key
					);
					$paramstring = http_build_query($params);
					$content = juhecurl($url,$paramstring);
					$result = json_decode($content,true);
					break;
				case 'lastJoketu':
					$url = "http://japi.juhe.cn/joke/img/text.from";
					$params = array(
						  "page" => $_POST['page'],//当前页数,默认1
						  "pagesize" => "20",//每次返回条数,默认1,最大20
						  "key" => $appkey,//您申请的key
					);
					$paramstring = http_build_query($params);
					$content = juhecurl($url,$paramstring);
					$result = json_decode($content,true);
					break;
				case 'lastserJoketu':
					$url = "http://japi.juhe.cn/joke/img/list.from";
					$params = array(
						  "sort" => "desc",//类型，desc:指定时间之前发布的，asc:指定时间之后发布的
						  "page" => $_POST['page'],//当前页数,默认1
						  "pagesize" => "20",//每次返回条数,默认1,最大20
						  "time" => time(),//时间戳（10位），如：1418816972
						  "key" => $appkey,//您申请的key
					);
					$paramstring = http_build_query($params);
					$content = juhecurl($url,$paramstring);
					$result = json_decode($content,true);
					break;
			}
			if($result){
				if($result['error_code']=='0'){
					//print_r($result);
					$data = $result['result']['data'];
					$i = 1;
					foreach($data as $value)
					{
						if(isset($value['url']))
						{
							echo '<p><span styel="font-size:1.23em">'.$i++.'</span>('.$value['updatetime'].') .'.$value['content'].'<br><span class="image"><img src="'.$value['url'].'"></span></p>';
						}
						else
						{
							echo '<p><span styel="font-size:1.23em">'.$i++.'</span>('.$value['updatetime'].') .<br><span class="content">'.$value['content'].'</span></p>';
						}
					}
				}else{
					echo $result['error_code'].":".$result['reason'];
				}
			}else{
				echo "请求失败";
			}
		}

		if($id == 'SearthMv')
		{
			//var_dump($_POST);
			$appkey = "dee0b45b92d465e75faa316e0104f62b";
			if($_POST['item'] =='Mvname')
			{
				$url = "http://op.juhe.cn/onebox/movie/video";
				$params = array(
					  "key" => $appkey,//应用APPKEY(应用详细页查询)
					  "dtype" => "",//返回数据的格式,xml或json，默认json
					  "q" => $_POST['Mvname'],//影视搜索名称
				);
				$paramstring = http_build_query($params);
				$content = juhecurl($url,$paramstring);
				$result = json_decode($content,true);
				if($result){
					if($result['error_code']=='0'){
						//print_r($result);
						$datamv = $result['result'];
						echo '<div class="printmovie"><p><img src="'.$datamv['cover'].'"></p><h4>'.$datamv['title'].'('.$datamv['tag'].')</h4><p>演员：'.$datamv['act'].'</p><p>地区：'.$datamv['area'].'（'.$datamv['year'].'）。导演'.$datamv['dir'].'</p><p>描述：'.$datamv['desc'].'</p>';
						$video_rec = $datamv['video_rec'];
						echo '<h4>相关电影</h4>';
						foreach($video_rec as $valuemv)
						{
							echo '<p style="text-align:center;"><a href="'.$valuemv['detail_url'].'" target="_blank"><img src="'.$valuemv['cover'].'"><br>'.$valuemv['title'].'</a></p>';
						}
						echo '<h4>演员介绍</h4>';
						foreach($datamv['act_s'] as $valueact)
						{
							echo '<p style="text-align:center;"><a href="'.$valueact['url'].'" target="_blank"><img src="'.$valueact['image'].'"><br>'.$valueact['name'].'</a></p>';
						}
						echo '</div>';

					}else{
						echo $result['error_code'].":".$result['reason'];
					}
				}else{
					echo "请求失败";
				}
			}
			if($_POST['item'] =='Mvcity')
			{
				$url = "http://op.juhe.cn/onebox/movie/pmovie";
				$params = array(
					  "key" => $appkey,//应用APPKEY(应用详细页查询)
					  "dtype" => "",//返回数据的格式,xml或json，默认json
					  "city" => $_POST['Mvcity'],//城市名称
				);
				$paramstring = http_build_query($params);
				$content = juhecurl($url,$paramstring);
				$result = json_decode($content,true);
				if($result){
					if($result['error_code']=='0'){
						//print_r($result);
						$datamvct = $result['result'];
						echo '<div><p><a href="'.$datamvct['url'].'" target="_blank">'.$datamvct['title'].'</a> <a href="'.$datamvct['m_url'].'" target="_blank">图片</a></p>';
						echo '<h4 style="text-align:center;"><a href="'.$datamvct['data'][0]['link'].'" target="_blank">正在上映</a></h4>';
						foreach($datamvct['data'][0]['data'] as $datamv)
						{
							echo '<p>'.$datamv['tvTitle'].'（'.$datamv['subHead'].'）</p>';
							$datamv['grade'] = isset($datamv['grade'])? $datamv['grade'] : '';
							$datamv['gradeNum'] = isset($datamv['gradeNum'])? $datamv['gradeNum'] : '';
							echo '<p>导演：'.$datamv['director']['data'][1]['name'].' (评分：'.$datamv['grade'].'/'.$datamv['gradeNum'].') <a href="'.$datamv['iconlinkUrl'].'" target="_blank"><img src="'.$datamv['iconaddress'].'"></a></p>';
							echo '<p>更多：';
							foreach($datamv['more']['data'] as $more)
							{
								$more['link'] = isset($more['link'])? $more['link'] : '';
								$more['name'] = isset($more['name'])? $more['name'] : '';
								echo '<br><a href="'.$more['link'].'" target="_blank">'.$more['name'].'</a>';
							}
							echo '<br>'.$datamv['star']['showname'].'：';
							foreach($datamv['star']['data'] as $star)
							{
								$star['link'] = isset($star['link'])? $star['link'] : 'javascript:void(0);'; 
								$star['name'] = isset($star['name'])? $star['name'] : '';
								echo '<br> <a href="'.$star['link'].'" target="_blank">'.$star['name'].'</a> ';
							}
							echo '</p><p>'.$datamv['playDate']['showname'].'：'.$datamv['playDate']['data'].'</p>';
							echo '<p>'.$datamv['story']['showname'].'：'.$datamv['story']['data']['storyBrief'].'... <a href="" target="_blank"> more <a></p>';
							echo '<p>'.$datamv['type']['showname'].'：';
							foreach($datamv['type']['data'] as $typemv)
							{
								echo ' <a href="'.$typemv['link'].'" target="_blank">'.$typemv['name'].'</a> ';
							}
							echo '</p>';
						}
						echo '<h4 style="text-align:center;"><a href="'.$datamvct['data'][1]['link'].'" target="_blank">即将上映</a></h4>';
						foreach($datamvct['data'][1]['data'] as $datamv)
						{
							echo '<p>'.$datamv['tvTitle'].'</p>';
							//$datamv['grade'] = isset($datamv['grade'])? $datamv['grade'] : '';
							//$datamv['gradeNum'] = isset($datamv['gradeNum'])? $datamv['gradeNum'] : '';
							echo '<p>导演：'.$datamv['director']['data'][1]['name'].' <a href="'.$datamv['iconlinkUrl'].'" target="_blank"><img src="'.$datamv['iconaddress'].'"></a></p>';
							echo '<p>更多：';
							foreach($datamv['more']['data'] as $more)
							{
								$more['link'] = isset($more['link'])? $more['link'] : '';
								$more['name'] = isset($more['name'])? $more['name'] : '';
								echo '<br><a href="'.$more['link'].'" target="_blank">'.$more['name'].'</a>';
							}
							echo '<br>'.$datamv['star']['showname'].'：';
							foreach($datamv['star']['data'] as $star)
							{
								$star['link'] = isset($star['link'])? $star['link'] : 'javascript:void(0);'; 
								$star['name'] = isset($star['name'])? $star['name'] : '';
								echo '<br> <a href="'.$star['link'].'" target="_blank">'.$star['name'].'</a> ';
							}
							echo '</p><p>'.$datamv['playDate']['showname'].'：'.$datamv['playDate']['data'].'</p>';
							echo '<p>'.$datamv['story']['showname'].'：'.$datamv['story']['data']['storyBrief'].'... <a href="" target="_blank"> more <a></p>';
							echo '<p>'.$datamv['type']['showname'].'：';
							foreach($datamv['type']['data'] as $typemv)
							{
								echo ' <a href="'.$typemv['link'].'" target="_blank">'.$typemv['name'].'</a> ';
							}
							echo '</p>';
						}
					}else{
						echo $result['error_code'].":".$result['reason'];
					}
				}else{
					echo "请求失败";
				}
			}
		}
	}


	public function writeM()
	{
		//var_dump($_POST);
		$add = '<p>写入时间：'.sys_date('').'，作者（'.getRealIpAddr().'）</p>';
		$content = $add.'<div id="content">'.nl2br($_POST['content']).'</div>';
		$text = './filesNew/text/'.sys_date('ymdHis').'.data';
		$handle = fopen($text, "a");
		if(fwrite($handle,$content))
		{
			echo '提交成功！';
			$txth = fopen('./filesNew/text/textList(sys).data','a');
			$list = '<p><a href="'.$text.'">'.$_POST['title'].'</a>  <a href="javascript:void(0);" id="model.php?model=download&file='.$text.'" class="downconfirm">下载</a><p>';
			fwrite($txth,$list);
			fclose($txth );

		}
		fclose($handle);
	}

	public function download()
	{
		Header('Content-Type:text/html; charset=utf-8');
		extension('tcpdf');
		$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
		$sid = sys_date('ymdHis').'.pdf';

		$handle = fopen($_GET['file'],'r');
		$content = fread($handle,filesize($_GET['file']));
		fclose($handle);

		//$pdf->writeHTMLCell(0, 0, '', '', $content, 0, 1, 0, true, '', true);
		//$pdf->Output($sid, 'D');

		//header('Content-type: application/pdf'); 
		header('Content-type: application/octet-stream; charset=utf8');//下载动作的关键
		Header("Accept-Ranges: bytes");
		header("Content-Disposition: attachment; filename=".$sid); 
		
		echo $content;

		exit();
	}
	public function app()
	{
		Header('Content-Type:text/html; charset=utf-8');
		if(!isset($_POST['item'])) return;
		$item = $_POST['item'];
		if($item == 'create')
		{
			$data = $_POST['data'];
			$data['date'] = date("Y-m-d H:i:s");
			$data['ip'] = getIp();
			$data['appUrl'] = '/hyang/app/'.$data['name'].'/';
			$data['viewUrl'] = '/hyang/view/'.$data['name'].'/';
			$data['jsUrl'] = '/public/js/app/'.$data['name'].'/';
			$data['cssUrl'] = '/public/css/app/'.$data['name'].'/';
			$this->createApp($data['name']);
			$this->console(json_encode($data),'N',null,'virtualdb/module/'.$data['name'].'.json');
		}
		if($item == 'delete')
		{
			$name = trim($_POST['module']);
			$data['app'] = './hyang/app/'.$name.'/';
			$data['view'] = './hyang/view/'.$name.'/';
			$data['js'] = './public/js/app/'.$name.'/';
			$data['css'] = './public/css/app/'.$name.'/';
			$emg = null;
			foreach($data as $k=>$v)
			{
				if ($dw = opendir($v)){	
					$n= 0;
					while(($fscan = readdir($dw)) !== false){
						if(strlen($fscan)>3)
						{
							if(unlink($v.$fscan)){
								$n += 1;
								$list = '<li>'. ltrim($v.$fscan,".").'</li>';
							}
						}
					}
					if(@unlink(dirname(__FILE__).'/virtualdb/module/'.$name.'.json')){
						$n += 1;
						$list = '<li>'.'/virtualdb/module/'.$name.'.json'.'</li>';
					}
					$emg .= ($name.'=>'.$k).(rmdir($v)? '（成功）': '（失败）').'<br>';
				}
			}
			echo (($emg)? $emg.'<p>注：共删除文件数：'.$n.'</p>'.'<ul>'.$list.'</ul>' : null);
		}
		if($item == 'AddJson')
		{
			$module = $_POST['module'];
			$str = $this->contents('virtualdb/module/'.$module.'.json',true);
			echo $str;
		}
		if($item == 'export')
		{
			$module = $_POST['module'];
			$app = '/hyang/app/'.$module.'/';
			$view = '/hyang/view/'.$module.'/';
			$js = '/public/js/app/'.$module.'/';
			$css = '/public/css/app/'.$module.'/';
			$zip = new ZipArchive;
			$model = $zip -> open($module.'.zip',ZipArchive::CREATE);
			$zip->addEmptyDir($app);
			$zip->addFile($app.$module.'class.php','.'.$app.$module.'class.php');
			$zip->addFile($app.$module.'model.php','.'.$app.$module.'model.php');
			$zip->addEmptyDir($view);
			//foreach($this-> printDir('.'.$view,true) as $v){}
			$zip->addEmptyDir($js);
			$zip->addEmptyDir($css);
			$zip -> close();
		}
	}
}
?>